<?php

require 'db.php';
require 'sign up.html';

$username = $_POST [ 'username' ];
$password = $_POST [ 'password' ];
$confirm = $_POST [ 'confirm' ];
$email = $_POST [ 'email' ];

// if ( $username == "" || $password == "" || $confirm == "" || $email == "" )
// {
//     echo "<script>alert('信息不能为空！重新填写')</script>" ;

// } else if (( strlen ( $username ) < 3)||(!preg_match( '/^\w+$/i' , $username ))) {
//     echo "<script>alert('用户名至少3位且不含非法字符！重新填写')</script>" ;

//     //判断用户名长度
// } else if ( strlen ( $password ) < 5){
//     echo "<script>alert('密码至少5位！重新填写')</script>" ;

//     //判断密码长度
// } else if ( $password != $confirm ) {
//     echo "<script>alert('两次密码不相同！重新填写')</script>" ;

//     //检测两次输入密码是否相同
// } else if (!preg_match( '/^[\w\.]+@\w+\.\w+$/i' , $email )) {
//     echo "<script>alert('邮箱不合法！重新填写')</script>" ;
//     //判断邮箱格式是否合法
// }  else if (mysqli_fetch_all(mysqli_query( $link , "select * from login where username = '$username'" ))){
//     echo "<script>alert('用户名已存在')</script>" ;
// } else {
//     $strsql = "insert into login(username, password, confirm, email)values('$username','$password','$confirm','$email')" ;
//      $result = mysqli_query($link, $strsql);
//      $data = mysqli_fetch_all($result);
//     //插入数据库
//     if (!$result == false){
//         echo "<script>alert('数据插入失败')</script>" ;
//     } else {
//         echo "<script>alert('注册成功！)</script>" ;
//     }
// }



// mysqli_free_result($result);
// mysqli_close($link);


?>



